#version 330 core

in vec2 TexCoords;
in vec4 fColor;
in vec2 fEffect;

uniform sampler2D texture0;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;
uniform sampler2D texture4;
uniform sampler2D texture5;
uniform sampler2D texture6;
uniform sampler2D texture7;
uniform sampler2D texture8;
uniform sampler2D texture9;
uniform sampler2D texture10;
uniform sampler2D texture11;
uniform sampler2D texture12;
uniform sampler2D texture13;
uniform sampler2D texture14;
uniform sampler2D texture15;

vec4 selectTexture(int index)
{
	vec4 col;
	switch(index)
	{
		case 0: col = texture(texture0, TexCoords); break;
		case 1: col = texture(texture1, TexCoords); break;
		case 2: col = texture(texture2, TexCoords); break;
		case 3: col = texture(texture3, TexCoords); break;
		case 4: col = texture(texture4, TexCoords); break;
		case 5: col = texture(texture5, TexCoords); break;
		case 6: col = texture(texture6, TexCoords); break;
		case 7: col = texture(texture7, TexCoords); break;
		case 8: col = texture(texture8, TexCoords); break;
		case 9: col = texture(texture9, TexCoords); break;
		case 10: col = texture(texture10, TexCoords); break;
		case 11: col = texture(texture11, TexCoords); break;
		case 12: col = texture(texture12, TexCoords); break;
		case 13: col = texture(texture13, TexCoords); break;
		case 14: col = texture(texture14, TexCoords); break;
		case 15: col = texture(texture15, TexCoords); break;
		default:
			col = vec4(1.0f, 1.0f, 1.0f, 1.0f);
	}
	return col;
}

void main()
{
	vec4 t = selectTexture(int(fEffect.x));
	if(fEffect.y == 0.0f)
		gl_FragColor = t * fColor;
	else
		gl_FragColor = vec4(1.0f, 1.0f, 1.0f, t.r) * fColor;
}